<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/layui-v2.6.3/css/public.css" media="all">
    <link rel="stylesheet" href="../../static/layui-v2.6.3/css/layui.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="startTime" autocomplete="off" class="layui-input" id="startTime" readonly="readonly">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="endTime" autocomplete="off" class="layui-input" id="endTime" readonly="readonly">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">转账类型</label>
                            <div class="layui-input-inline">
                                 <select class="layui-select-group" name="payType" id="payType">
                                     <option value="全部" selected="selected">全部</option>
                                     <option value="转款">转款</option>
                                     <option value="提现">提现</option>
                                     <option value="充值">充值</option>
                                 </select>
                            </div>
                        </div>
						<div class="layui-inline">
						    <label class="layui-form-label">交易有效时间</label>
						    <div class="layui-input-inline">
						         <select class="layui-select-group" name="payTime" id="payTime">
						             <option value="一个月" selected="selected">一个月</option>
						             <option value="三个月">三个月</option>

						         </select>
						    </div>
						</div>
                        <div class="layui-inline">
                            <button type="button" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>



        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>



    </div>
</div>
<script src="/static/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script th:inline="none">
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/ecis/trade/findByCondition',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'id', width: 150, title: '交易单号', sort: true,align:'center'},
                {field: 'payerUsername', width: 150, title: '付款人',align:'center'},
                {field: 'payerIdent', width: 150, title: '付款人标识', sort: true,align:'center'},
                {field: 'payeeUsername', width: 150, title: '收款人',align:'center'},
                {field: 'payeeIdent', width:150,title: '收款人标识', minWidth: 150,align:'center'},
                {field: 'price', width:150,title: '余额', minWidth: 150,align:'center'},
                {field: 'payType', width: 150, title: '交易类型', sort: true,align:'center'},
                {field: 'gmtCreated', width: 250, title: '交易时间', sort: true,align:'center'},
            ]],
            limits: [5, 10, 15, 20, 25, 30],
            limit: 5,
            page: true,
            skin: 'line'
        });

		layui.use('laydate',function(){
			var laydate=layui.laydate;
			var startDate=laydate.render({
				elem: '#startTime',
				done: function(value, date) {
					// 结束时间大于开始时间
					if (value !== '') {
						endDate.config.min.year = date.year;
						endDate.config.min.month = date.month - 1;
						endDate.config.min.date = date.date;
					} else {
						endDate.config.min.year = '';
						endDate.config.min.month = '';
						endDate.config.min.date = '';
					}
				}
			});
			var endDate=laydate.render({
				elem: '#endTime',
				done: function(value, date) {
					// 开始时间小于结束时间
					if (value !== '') {
						startDate.config.max.year = date.year;
						startDate.config.max.month = date.month - 1;
						startDate.config.max.date = date.date;
					} else {
						startDate.config.max.year = '';
						startDate.config.max.month = '';
						startDate.config.max.date = '';
					}
				}
			})
		});

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
			console.log(result);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result,
					startTime: $('#startTime').val(),
					endTime: $('#endTime').val(),
					payType: $('#payType').val(),
					payTime: $('#payTime').val()
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

    });
</script>

</body>
</html>
